package com.lagou.edu.service.impl;

import com.lagou.edu.dao.UserDao;
import com.lagou.edu.entity.User;
import com.lagou.edu.service.UserService;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Service;

import java.util.Optional;

/**
 * @Author: yeqingyun
 * @Date: 2020/11/20 16:34
 */
@Service
@RequiredArgsConstructor
public class UserServiceImpl implements UserService {

    private final UserDao userDao;

    @Override
    public Optional<User> getByEmail(String email) {
        User user = new User();
        user.setEmail(email);
        return userDao.findOne(Example.of(user));
    }

    @Override
    public void add(User user) {
        userDao.save(user);
    }
}
